package com.feeyo.groundservice.composewidget.usage

import android.os.Bundle
import androidx.activity.compose.setContent
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.mutableIntStateOf
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.feeyo.groundservice.composewidget.R
import com.feeyo.groundservice.composewidget.usage.base.BaseComposeActivity
import com.feeyo.groundservice.composewidget.util.dimenToDp
import com.feeyo.groundservice.composewidget.util.toComposeColor
import com.feeyo.groundservice.composewidget.view.tab.SwitchButton
import com.feeyo.groundservice.composewidget.view.tab.SwitchTab
import com.feeyo.groundservice.composewidget.view.tab.TabCountPosition
import com.feeyo.groundservice.composewidget.view.tab.TabRowItem
import com.feeyo.groundservice.composewidget.view.util.VerticalSpace

/**
 *作者：70893 on 2025-03-27
 *描述：Switch Tab
 */
class SwitchActivity : BaseComposeActivity() {


    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        initView()
    }

    private fun initView() {
        setContent {
            Column(
                modifier = Modifier.fillMaxSize().padding(20.dp)
            ) {

                SwitchButton(
                    open = false,
                    onSwitch = {},
                    padding = R.dimen.d1.dimenToDp()
                )
                VerticalSpace(dp = 20.dp)
                SwitchButton(
                    open = true,
                    onSwitch = {},
                )

                VerticalSpace(dp = 20.dp)
                SwitchButton(
                    open = true,
                    onSwitch = {},
                    padding = 3.dp
                )

                VerticalSpace(dp = 20.dp)
                //滑块是圆形的
                SwitchButton(
                    open = true,
                    onSwitch = {},
                    bottomWidth = 80.dp,
                    bottomHeight = 40.dp,
                )
                VerticalSpace(dp = 20.dp)
                //滑块是圆形的，带内边距的
                SwitchButton(
                    open = true,
                    onSwitch = {},
                    bottomWidth = 80.dp,
                    bottomHeight = 43.dp,
                    padding = 3.dp,
                    slideBarBorderOpen = true,
                    slideBarBorderOpenColor = R.color.blue_2E76EE.toComposeColor(),
                    slideBarBorderCloseColor = R.color.gray_D4.toComposeColor(),
                )
                VerticalSpace(dp = 20.dp)

                //tab

                val tabs = arrayListOf(
                    TabRowItem(
                        title = "全部",
                        count = remember { mutableIntStateOf(0) }
                    ),
                    TabRowItem(
                        title = "到位",
                        count = remember { mutableIntStateOf(1) }
                    ),
                    TabRowItem(
                        title = "开始",
                        count = remember { mutableIntStateOf(2) }
                    ),
                    TabRowItem(
                        title = "结束",
                        count = remember { mutableIntStateOf(3) }
                    ),
                    TabRowItem(
                        title = "结束1",
                        count = remember { mutableIntStateOf(3) }
                    ),
                    TabRowItem(
                        title = "结束2",
                        count = remember { mutableIntStateOf(3) }
                    )
                )

                SwitchTab(
                    tabRowItems = tabs,
                    tabCountDirection = TabCountPosition.LEFT,
                    onSelectIndex = {

                    },
                )

                VerticalSpace(dp = 20.dp)
                SwitchTab(
                    tabRowItems = tabs,
                    bottomHeight = R.dimen.d70.dimenToDp(),
                    padding = R.dimen.d3.dimenToDp(),
                    tabCountDirection = TabCountPosition.TOP,
                    slideBarWidth = R.dimen.d60.dimenToDp(),
                    slideBarGapWidth = R.dimen.d10.dimenToDp(),
                    onSelectIndex = {

                    },
                )

                VerticalSpace(dp = 20.dp)
                SwitchTab(
                    tabRowItems = tabs,
                    tabCountDirection = TabCountPosition.END,
                    bottomCornerRadius = R.dimen.d5.dimenToDp(),
                    slideBarCornerRadius = R.dimen.d5.dimenToDp(),
                    onSelectIndex = {

                    },
                )

                VerticalSpace(dp = 20.dp)
                SwitchTab(
                    tabRowItems = tabs,
                    tabCountDirection = TabCountPosition.BOTTOM,
                    bottomCornerRadius = R.dimen.d5.dimenToDp(),
                    slideBarWidth = R.dimen.d100.dimenToDp(),
                    bottomHeight = R.dimen.d70.dimenToDp(),
                    slideBarCornerRadius = R.dimen.d8.dimenToDp(),
                    slideBarBorderColor = R.color.red_EB5451.toComposeColor(),
                    slideBarBorderOpen = true,
                    onSelectIndex = {

                    },
                )
            }
        }
    }
}